axios.defaults.baseURL = 'https://hmajax.itheima.net'

class Toast {
    constructor() {
        this.toast = document.querySelector('.my-toast')
    }
    show(msg) {
        this.toast.querySelector('.toast-body').textContent = msg
        new bootstrap.Toast(this.toast).show()
    }
}

class DataServes {
    async register(data) {
        const config = {
            url: '/register',
            method: 'POST',
            data
        }
        try {
            return await axios(config)
        } catch (err) {
            console.log(new Error(err))
            throw (err)
        }
    }

    async login(data) {
        try {
            return await axios.post('/login', data)
        } catch (err) {
            console.log(new Error(err))
            throw (err)
        }
    }
}

class UserAccessBase {
    constructor() {
        this.dataServes = new DataServes()
        this.passwordInp = document.getElementById('input-password')
        this.seeBtn = document.querySelector('.input-group-text a')
        this.toast = new Toast()
    }

    init() {
        this.bindEvents()
    }

    bindEvents() { }
}